<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

	<ui:composition template="/template.xhtml">
		
		<ui:define name="content">
			<p:layoutUnit position="west" size="200" style="border:none;">  
		    </p:layoutUnit>  
		  
		    <p:layoutUnit position="east" size="200" style="border:none;">  
		    </p:layoutUnit>  
		    
			<p:layoutUnit position="center" styleClass="telaPrincipal"> 
				<div align="center">
					<p:panel header="Cadastro de Modulos">
						<h:form id="formCadastroModulo">
							<p:panelGrid>	
								<p:row>
									<p:column>
										<h:outputLabel for="nome-modulo" value="Módulo: " />
									</p:column>
									<p:column colspan="3">
										<p:inputText id="nome-modulo" size="50" value="#{moduloBean.modulo.modulo}" required="true" requiredMessage="Nome do modulo é um campo obrigatório." />
									</p:column>
									<p:column><h:outputLabel for="media-modulo" value="Media: " /></p:column>
									<p:column><p:inputText id="media-modulo" size="20" value="#{moduloBean.modulo.media}"/></p:column>
								</p:row>
							
								<p:row>
									<p:column>
										<h:outputLabel for="cor-modulo" value="Cor:" />
									</p:column>
									<p:column>
										<h:selectOneMenu id="cor-modulo" value="#{moduloBean.modulo.cor}">
											<f:selectItem itemLabel="Preto" itemValue="black" />  
											<f:selectItem itemLabel="Vermelho" itemValue="red" />
										</h:selectOneMenu>
									</p:column>
									<p:column>
										<h:outputText value="Recebido: " />
									</p:column>
									<p:column>
										<p:selectBooleanButton value="#{moduloBean.modulo.recebido}" onLabel="Sim" offLabel="Não" onIcon="ui-icon-check" offIcon="ui-icon-close"/>
									</p:column>
									
									<p:column>
										<h:outputText value="Pago: " />
									</p:column>
									<p:column>
										<p:selectBooleanButton value="#{moduloBean.modulo.pago}" onLabel="Sim" offLabel="Não" onIcon="ui-icon-check" offIcon="ui-icon-close"/>
									</p:column>
								</p:row>
								<p:row>
									<p:column colspan="6">
										<div align="right">
											<p:commandButton value="Salvar" id="btnAddMod" actionListener="#{moduloBean.adicionarModulo}" ajax="false" icon="ui-icon-plusthick" />
										</div>
									</p:column>
								</p:row>
							</p:panelGrid>
						</h:form>
						
						<h:form id="listarModulos">
							<p:panel header="Modulos Cadastrados" >
								<p:dataTable id="tabelaModulos" value="#{moduloBean.listaModulos}" var="modulo">
									<p:column headerText="Modulo">
										<h:outputText value="#{modulo.modulo}" style="color: #{modulo.cor};" styleClass="textoNegrito"/>
									</p:column>
				
									<p:column headerText="Media" width="10%">
										<div align="center">
											<h:outputText value="#{modulo.media}" style="color: #{modulo.cor};" styleClass="textoNegrito"/>
										</div>
									</p:column>
				
									<p:column headerText="Recebido" width="10%">
										<div align="center">
											<p:selectBooleanButton value="#{modulo.recebido}" onLabel="Sim" offLabel="Não" disabled="true" style="color: #{modulo.cor}; opacity: 1; border: none;"/>
										</div>
									</p:column>
				
									<p:column headerText="Pago" width="10%">
										<div align="center">
											<p:selectBooleanButton value="#{modulo.pago}" onLabel="Sim" offLabel="Não" disabled="true" style="color: #{modulo.cor}; opacity: 1; border: none;"/>
										</div>
									</p:column>
									
									<p:column headerText="Editar" width="10%">
										<div align="center">
											<p:commandButton icon="ui-icon-pencil" actionListener="#{moduloBean.editarModulo}" oncomplete="dialogAdicionarModulo.show()" update="@([id$=adicionarModuloDialog])">
												<f:param name="modulo" value="#{modulo}" />
											</p:commandButton>
										</div>
									</p:column>
				
									<p:column headerText="Excluir" width="10%">
										<div align="center">
											<p:commandButton icon="ui-icon-trash" actionListener="#{moduloBean.removerModulo}">
												<f:param name="modulo" value="#{modulo}" />
											</p:commandButton>
										</div>
									</p:column>
								</p:dataTable>
							</p:panel>
						</h:form>
					
						<h:form id="formMenu">
							<div align="right">
								<p:commandButton id="btn-back" actionListener="#{alunoBean.voltarParaCadastro}" value="Voltar" icon="ui-icon-seek-prev" style="margin:10px"/>
								<p:commandButton id="btn-cad-obs" actionListener="#{arquivoBean.avancarObservacoes}" value="Avançar" icon="ui-icon-seek-next" style="margin:10px"/>
							</div>
						</h:form>
					</p:panel>
				</div>
			</p:layoutUnit>
		</ui:define>
	</ui:composition>
</html>